Skip to content

List possible values for configuration enums #15216

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

BenjaminBrienen
Copy link

@BenjaminBrienen BenjaminBrienen commented Jul 6, 2025

I had to look at clippy's implementation to see what the possible enum values were, so I am making it possible for that information to be more visible with this change.

changelog: Improved lint configuration documentation to show possible enumeration values.

@rustbot
Copy link
Collaborator

rustbot commented Jul 6, 2025

r? @flip1995

rustbot has assigned @flip1995.
They will have a look at your PR within the next two weeks and either review your PR or reassign to another reviewer.

Use r? to explicitly pick a reviewer

@rustbot rustbot added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties label Jul 6, 2025
@BenjaminBrienen
Copy link
Author

Feel free to give advice about how this can be done less "hardcoded". Unfortunately, iterating over enums isn't a rust thing.

@blyxyas
Copy link
Member

blyxyas commented Jul 6, 2025

I'm not sure about making it less hardcoded, but what could be a very appreciated addition to this PR is checking for the possible values array on update_lints or on test via mem::variant_count

@y21
Copy link
Member

y21 commented Jul 6, 2025

Unfortunately, iterating over enums isn't a rust thing.

Depending on how much we want this, this could be emulated with not too much work by wrapping the enum definition around a macro that outputs an associated const with the variant names: https://play.rust-lang.org/?version=stable&mode=debug&edition=2024&gist=11528b07df66ce90ac71c72b279887c2

@BenjaminBrienen
Copy link
Author

I like the idea, but I'm not sure how to make define_Conf support either an array of values (good if we want to put something custom like "any type name") or a const expression.

@BenjaminBrienen
Copy link
Author

I'm not familiar enough with update_lints to make the other suggestion in a short amount of time, so I'm going to leave it like this for now.

@flip1995
Copy link
Member

flip1995 commented Jul 7, 2025

r? @y21 I'll let you shepherd this PR through. I like the idea, but don't have the time to do the necessary investigations/suggestions on how to make this more automated.

@rustbot rustbot assigned y21 and unassigned flip1995 Jul 7, 2025
Co-authored-by: Alejandra González <blyxyas@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-review Status: Awaiting review from the assignee but also interested parties
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants